<template>
  <div class="algoInfo">
    <div v-for="(info, index) in infoDataConfig" :key="'info' + index" class="card-footer-row">
      <p class="left-caption">{{ info.label }}</p>
      <!--      <p v-if="info.label === '文档'" class="right-content">-->
      <!--        <el-link v-if="info.valueHandle(nodeData)" :href="info.valueHandle(nodeData)" target="_blank" type="primary">链接</el-link>-->
      <!--      </p>-->
      <p v-if="info.label === '说明'" class="right-content" v-html="info.valueHandle(nodeData)" />
      <p v-else class="right-content">{{ info.valueHandle(nodeData) }}</p>
    </div>
  </div>
</template>

<script>
import { formatDate } from 'src/utils/designerTool/toole';
export default {
  name: 'AlgoInfo',
  components: {},
  props: {
    nodeData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    infoConfig: {
      type: Array,
      default: () => {
        return null
      }
    }
  },
  data() {
    return {}
  },
  computed: {
    docUrl() {
      return ''
    },
    infoDataConfig() {
      if (this.infoConfig) {
        return this.infoConfig
      } else {
        return [
          {
            label: '说明',
            valueHandle: (data) => {
              return data.description
            }
          },
          {
            label: '输入个数',
            valueHandle: (data) => {
              let num = 0
              if (data.configs == undefined) return
              data.configs.forEach(item => {
                if (item.param_type == 'input') {
                  num++
                }
              })
              if (num == 0) {
                return null
              } else {
                return num
              }
            }
          },
          {
            label: '输出个数',
            valueHandle: (data) => {
              let num = 0
              if (data.configs == undefined) return
              data.configs.forEach(item => {
                if (item.param_type == 'output') {
                  num++
                }
              })
              return num
            }
          },
          {
            label: '版本',
            valueHandle: (data) => {
              return data?.version
            }
          },
          {
            label: '更新时间',
            valueHandle: (data) => {
              return data.update_time
            }
          }
        ]
      }
    }
  }
}

</script>

<style lang="scss" scoped>
.algoInfo {
  .card-footer-row {
    line-height: 1.5em;
    padding: 3px 0;
    display: flex;

    .left-caption {
      margin: 0 8px 0 0;
      color: #808695;
      display: inline-block;
      width: 64px;
      flex: 0 0 auto;
      text-align: right;

      &:after {
        display: inline-block;
        content: ":";
        margin-left: 2px;
      }
    }

    .right-content {
      word-break: break-all;
      color: #333;
      display: inline-block;
      margin: 0;
    }
  }
}
</style>
